package cn.pzhu.controller.admin;

import cn.pzhu.controller.BaseController;
import cn.pzhu.services.admin.PrivilegeServices;
import cn.pzhu.services.admin.UserServices;

import java.util.List;

/**
 * Created by dongp on 2016/4/23.
 */
public class PrivilegeController extends BaseController {

    private PrivilegeServices privilegeServices = new PrivilegeServices();

    public void index() {
        render("privilege.jsp");
    }

    public void ajaxAdd() {
        String privilegeID = getPara("privilegeID");
        String masterVal = getPara("masterVal");
        String accessName = getPara("accessName");
        String accessVal = getPara("accessVal");

        boolean result = privilegeServices.ajaxAdd(privilegeID,masterVal,accessName,accessVal);
        render("privilege.jsp");
    }

    public void ajaxQuery() {
        String pageNumber = getPara("pageNumber");
        String pageSize = getPara("pageSize");
        String search = getPara("search","");
        List attrs = privilegeServices.ajaxQuery(pageNumber,pageSize,search);
        renderJson(attrs);
    }

    public void ajaxUpdate() {
        String privilegeID = getPara("privilegeID");
        String masterVal = getPara("masterVal");
        String accessName = getPara("accessName");
        String accessVal = getPara("accessVal");

        boolean result = privilegeServices.ajaxUpdate(privilegeID,masterVal,accessName,accessVal);
        if(result) {
            setAttr("msg","success");// 该返回的成功信息前台暂时没用
        }else {
            setAttr("msg","failue");
        }

        render("privilege.jsp");
    }

    public void ajaxDel() {
        String privilegeID = getPara("privilegeID");
        boolean result = privilegeServices.ajaxDel(privilegeID);

        render("privilege.jsp");
    }
}
